package com.wxp.mvc.util;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import com.wxp.mvc.ActionForm;

public class FullForm {

	@SuppressWarnings("rawtypes")
	public static ActionForm full(String formClass, HttpServletRequest request) {
		ActionForm form = null;
		try {
			Class clazz = Class.forName(formClass);
			form = (ActionForm) clazz.newInstance();
			Field[] fieldArray = clazz.getDeclaredFields();
			for (Field field : fieldArray) {
				field.setAccessible(true);
				field.set(form, request.getParameter(field.getName()));
				field.setAccessible(false);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return form;
	}

	public static void main(String[] args) {
		String uri = "/userList.do";
		System.out.println(uri.split("\\.")[0]);
	}
	
}
